package com.cnap.model.schedule.engine;

import cn.hutool.core.text.CharSequenceUtil;
import com.cnap.utils.JsonUtil;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

/**
 * 部署策略计算请求
 *
 * @author xc
 **/
public class DeployPolicyRequest {
    // 服务id
    @JsonProperty(value = "svcId")
    private String serviceId;
    // 部署配置
    private String deployPolicyConfig;
    // yaml
    private String yaml;
    // 应用分类
    private String appCategory;
    // 场景标签
    @JsonProperty(value = "sceneTag")
    private List<String> sceneTags;
    // 计数标签
    @JsonProperty(value = "technologyTag")
    private List<String> technologyTags;
    // 用户名
    private String userName;
    // 是否强制隔离
    private boolean forcedIsolation;

    /**
     * get
     *
     * @return ForcedIsolation
     */
    public boolean isForcedIsolation() {
        return forcedIsolation;
    }

    /**
     * set
     *
     * @param forcedIsolation forcedIsolation
     */
    public void setForcedIsolation(boolean forcedIsolation) {
        this.forcedIsolation = forcedIsolation;
    }

    /**
     * get
     *
     * @return ServiceId
     */
    public String getServiceId() {
        return serviceId;
    }

    /**
     * set
     *
     * @param serviceId serviceId
     */
    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }

    /**
     * get
     *
     * @return DeployPolicyConfig
     */
    public String getDeployPolicyConfig() {
        return deployPolicyConfig;
    }

    /**
     * set
     *
     * @param deployPolicyConfig deployPolicyConfig
     */
    public void setDeployPolicyConfig(String deployPolicyConfig) {
        this.deployPolicyConfig = deployPolicyConfig;
    }

    /**
     * get
     *
     * @return Yaml
     */
    public String getYaml() {
        return yaml;
    }

    /**
     * set
     *
     * @param yaml yaml
     */
    public void setYaml(String yaml) {
        this.yaml = yaml;
    }

    /**
     * get
     *
     * @return AppCategory
     */
    public String getAppCategory() {
        return appCategory;
    }

    /**
     * set
     *
     * @param appCategory appCategory
     */
    public void setAppCategory(String appCategory) {
        this.appCategory = appCategory;
    }

    /**
     * get
     *
     * @return SceneTags
     */
    public List<String> getSceneTags() {
        return sceneTags;
    }

    /**
     * set
     *
     * @param sceneTags sceneTags
     */
    public void setSceneTags(List<String> sceneTags) {
        this.sceneTags = sceneTags;
    }

    /**
     * get
     *
     * @return TechnologyTags
     */
    public List<String> getTechnologyTags() {
        return technologyTags;
    }

    /**
     * set
     *
     * @param technologyTags technologyTags
     */
    public void setTechnologyTags(List<String> technologyTags) {
        this.technologyTags = technologyTags;
    }

    /**
     * get
     *
     * @return UserName
     */
    public String getUserName() {
        return userName;
    }

    /**
     * set
     *
     * @param userName userName
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * 转换成合法的json
     *
     * @return json
     */
    public String transToJsonStr() {
        String config = deployPolicyConfig;
        setDeployPolicyConfig(null);
        String str = JsonUtil.objectToJsonStr(this);
        if (CharSequenceUtil.isEmpty(str)) {
            return null;
        }
        return str.replace("null", config);
    }
}
